<template>
	<view>
		<view class="amount">
			<text>￥</text>{{payInfo.showPrices}}
		</view>
		<view class="pay-tips">支付金额</view>

		<view class="pay-info-item">
			<view class="film-title">{{payInfo.filmName}}</view>
			<view class="film-text">
				<text>订单号：</text>
				<text>{{payInfo.outOrderSn}}</text>
			</view>
			<view class="film-text">
				<view v-for="(value,index) in payInfo.zuowei" :key="index">
					<text> {{value.seatName}}</text>
					<text v-if="index < payInfo.zuowei.length - 1">，</text>
				</view>
			</view>
		</view>
		<view class="pay-modular" v-for="(value,index) in payList" :key="index" @click="getPayTab(index)">
			<view class="pay-mode">
				<image :src="value.img"></image>
				<text>{{value.tel}}</text>
			</view>
			<image :src="('../../static/sjimg/pay-sele-'+(index==payIndex?'yes':'no')+'.png')" class="pay-select">
			</image>
		</view>
		<view class="pay-btns" @click="buy">确认支付</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { onShow , onLoad } from '@dcloudio/uni-app';
	import { apiGetmodet , apiMvorder , apiPay } from '@/api/upapi.js';
	
	const payInfo= ref({});
	const types= ref('');
	const payIndex = ref(0);
	const payList = ref([
		{ tel: '支付宝支付', img: ('../../static/sjimg/zzfb.png') }
	]);
	
	const getPayTab = (index) => {
		if (payIndex.value != index) { payIndex.value = index }
	};
	const buy = ()=>{
		if(payIndex.value==0){
			buys();
		}
	};
	const buys = async ()=>{
		uni.showToast({ title: '暂未开放', icon: 'none' })
		// const merInfo = uni.getStorageSync('xwmemberInfo');
		// try {
		// 	let res = await apiPay({
		// 		openid: merInfo.openid,
		// 		bid:payInfo.value.outOrderSn,
		// 		type:2,
		// 		orderPrice:payInfo.value.orderPrice,
		// 		pay_amt:payInfo.value.showPrices,
		// 		merchant_no:6201001000
		// 	});
		// 	if (res.data.result == 0) {
		// 		var data = JSON.parse(res.data.object);
		// 		uni.requestPayment({
		// 			appId: data.appId,
		// 			provider: 'wxpay',
		// 			timeStamp: data.timeStamp,
		// 			nonceStr: data.nonceStr,
		// 			package: data.package,
		// 			signType: data.signType,
		// 			paySign: data.paySign,
		// 			success: function(res) {
		// 				uni.showToast({ title: '支付成功', icon: 'none' })
		// 				uni.switchTab({ url:'/pages/index/car' })
		// 			},
		// 			fail: function(err) {}
		// 			});
		// 	} else {
		// 		uni.showToast({ title: res.data.msg,icon:'none'  });
		// 	}
		// } catch (error) {
		// 	console.error('获取数据失败', error);
		// }
	};
	
	onLoad((option) => {
	    const data = JSON.parse(decodeURIComponent(option.data));
		data.showPrices = parseFloat(Number(data.showPrices / 100).toFixed(2));
		data.orderPrice = parseFloat(Number(data.orderPrice / 100).toFixed(2));
		payInfo.value=data;
	});
</script>

<style lang="less">
	page {
		background-color: #F4F5F7;
	}

	.amount {
		text-align: center;
		padding-top: 80rpx;
		color: #FE602B;
		font-size: 72rpx;
		font-weight: 550;

		text {
			font-size: 36rpx;
		}
	}

	.pay-tips {
		text-align: center;
		color: #636775;
		font-size: 28rpx;
		margin-top: 6rpx;
	}

	.pay-info-item {
		margin: 70rpx 30rpx 0rpx 30rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		padding:30rpx;

		.film-title {
			color: #2D3039;
			font-size: 36rpx;
			font-weight: 550;
			padding-bottom: 8rpx;
		}

		.film-text {
			margin-top: 12rpx;
			color: #636775;
			font-size: 28rpx;
			display: flex;
			align-items: center;
		}
	}

	.pay-item {
		margin: 20rpx 30rpx 0rpx;
		background-color: #FFFFFF;
		border-radius: 16rpx;
		padding:30rpx;
		display: flex;
		align-items: center;

		.item-left {
			display: flex;
			align-items: center;

			image {
				width: 48rpx;
				height: 48rpx;
			}

			text {
				color: #2D3039;
				font-size: 28rpx;
				margin-left: 20rpx;
			}
		}

		.pay-check {
			margin-left: auto;
			width: 36rpx;
			height: 36rpx;
		}
	}

	.pay-btns {
		position: fixed;
		bottom: 50rpx;
		left: 32rpx;
		right: 32rpx;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		background-color: #FE602B;
		border-radius: 50rpx;
		color: #FFFFFF;
		font-size: 36rpx;
		font-weight: 550;
	}
	.pay-modular {
		margin: 24rpx 30rpx 0rpx;
		background-color: #FFFFFF;
		border-radius: 16rpx;
		padding: 32rpx 24rpx 28rpx 25rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	
		.pay-mode {
			display: flex;
			align-items: center;
	
			image {
				width: 44rpx;
				height: 44rpx;
			}
	
			text {
				color: #333333;
				font-size: 32rpx;
				font-weight: bold;
				margin-left: 16rpx;
			}
		}
	
	
		.pay-select {
			width: 44rpx;
			height: 44rpx;
		}
	}
</style>